from rest_framework import serializers
from .models import UserModel, PatientModel, Department, MedicalConsultationOrder


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = UserModel
        fields = ('name', 'mobile', 'password', 'email', 'pic_url')
        extra_kwargs = {'password': {'write_only': True}}  # 确保密码字段只在创建时不被返回

class UserSer(serializers.ModelSerializer):
    class Meta:
        model = UserModel
        fields = 'mobile'

class PatientSer(serializers.ModelSerializer):
    class Meta:
        model = PatientModel
        fields = '__all__'

class DepartmentSerSon(serializers.ModelSerializer):
    class Meta:
        model = Department
        fields = ('id', 'name')

class DepartmentSer(serializers.ModelSerializer):
    child = DepartmentSerSon(many=True)
    class Meta:
        model = Department
        fields = ('id', 'name', 'child')

class OrdersSer(serializers.ModelSerializer):
    class Meta:
        model = MedicalConsultationOrder
        fields = '__all__'
